package nm.aleksey.server;

import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

public final class EMF {
  private static EMF emf;

  public static EMF getInstance() {
    if (emf == null) {
      emf = new EMF();
    }
    return emf;
  }

  private EntityManagerFactory emfInstance;

  private EMF() {
  }

  public EntityManagerFactory get() {
    if (emfInstance == null) {
      emfInstance = Persistence
          .createEntityManagerFactory("transactions-optional");
    }
    return emfInstance;
  }
}

// public final class EMF {
// private static EntityManagerFactory emfInstance = Persistence
// .createEntityManagerFactory("transactions-optional");
//
// public static EntityManagerFactory get() {
// return emfInstance;
// }
//
// public EMF() {
// }
// }